import { connect } from 'umi';
import { SourceUpdateContext } from '../common/UpdateContext';
import { useUpdateReducer } from '../common/UpdateReducer';
import SourceUpdateView from './UpdateView';

const UpdateViewBox = ({ curRes, locationProps }) => {
  const prefixCls = 'source-manage-';

  const {
    Calibrate_Id,
    SourceInfo,
    projectInfo,
    Source_Invite,
    Invite_PackList,
    Source_Clarify,
    Source_PurchaseChange,
    Source_Calibrate,
    Source_CurrentStep,
    dispatch,
  } = useUpdateReducer();

  return (
    <SourceUpdateContext.Provider
      value={{
        curRes,
        projectInfo,
        prefixCls,
        SourceInfo,
        Source_Invite,
        locationProps,
        Invite_PackList,
        Calibrate_Id,
        dispatch,
        Source_Clarify,
        Source_PurchaseChange,
        Source_Calibrate,
        Source_CurrentStep,
      }}
    >
      <SourceUpdateView />
    </SourceUpdateContext.Provider>
  );
};

export default connect(({ baseLogin, navTab }: Record<string, any>) => ({
  curRes: baseLogin?.permissions,
  navTab,
}))(UpdateViewBox);
